package com.gwm.upload;

import com.aliyun.oss.OSS;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = GwmUploadApplication.class)
public class test {


    @Autowired
    private OSS ossClient;


    @Test
    public void upload2() throws FileNotFoundException {
        // 创建PutObjectRequest对象。
        InputStream fileInputStream = new FileInputStream("H:\\Image\\dd.png");
        //桶的名称,文件名称,创建一个字节数组流 然后把文件信息放入流中
        ossClient.putObject("work-gwm", "dd.png",fileInputStream);
        ossClient.shutdown();
        System.out.println("上传成功");
    }
}
